﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.IManager;
using Business.Manager;
using System.Data;

namespace OnlinePayment.Admin
{
    public partial class GuestbookBGView : System.Web.UI.Page
    {
        IGuestbookManager guestbookManager = new GuestbookManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                getclass();
            }

        }


        private void getclass()
        {
            
            DataTable dt = guestbookManager.getTable();
            this.GV_class.DataSource = dt.DefaultView;
            this.GV_class.DataBind();
        }


        protected void GV_class_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                this.GV_class.PageIndex = e.NewPageIndex;
                getclass();
            }
            catch
            {
 
            }
        }

        protected void DlPage_Init(object sender, EventArgs e)//DlPage就是分页中的下拉列表框
        {
            DropDownList list = (DropDownList)sender;
            for (int i = 1, j = GV_class.PageCount; i <= j; i++)
            {
                list.Items.Add(new ListItem(i.ToString()));
            }
            list.SelectedIndex = GV_class.PageIndex;
        }

        protected void DlPage_SelectedIndexChanged(object sender, EventArgs e)//DlPage就是分页中的下拉列表框
        {
            DropDownList list = (DropDownList)sender;
            GV_class.PageIndex = list.SelectedIndex;
            getclass();
        }

        protected void GV_class_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            
        }


        protected void GV_class_RowEditing(object sender, GridViewEditEventArgs e)
        {
            string smallclassid = this.GV_class.Rows[e.NewEditIndex].Cells[0].Text;
            Response.Redirect("admin_smallclassedit.aspx?smallclassid=" + smallclassid);
        }


        protected void GV_class_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            /*if (e.Row.RowType == DataControlRowType.DataRow)
            {
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()))
                {
                    e.Row.Cells[2].Text = bigclassbll.getbigclassdetail(cn, e.Row.Cells[2].Text).bigclassname;
                }
            }*/
        }



        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "GetInfo")
            {
                Response.Redirect("GuestbookReplyBGView.aspx?EntityId=" + Convert.ToInt32(e.CommandArgument));
                //Response.Redirect("../Home/GuestbookDetail.aspx?EntityId=" + Convert.ToInt32(e.CommandArgument));
                //Response.Write("<script>window.top.navigate('../Home/GuestbookDetail.aspx?EntityId=" + Convert.ToInt32(e.CommandArgument) + "');</script>");
　　　　　　　　
                
                //获取被点击的linkButton所在的GridViewRow
　　　　　　　　//GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); 
　　　　　　　　//int index = gvrow.RowIndex; //获取到行索引 RowIndex
　　　　　　　　　　　　
　　　　　　　　//获取当前行的某列值
                //string userid = GV_class.Rows[index].Cells[列索引].Text.Trim();

            }
            else if (e.CommandName == "Delete")
            {
                 guestbookManager.delete(Convert.ToString(e.CommandArgument));
                 getclass();
            }



        }





    }
    
}

/*
 
 
  <!-- CommandArgument='<%# Eval("EntityId") %>' CommandName="GetInfo"-->
 */